package icu.sehnen.rabbitmq.controller;

import icu.sehnen.common.CommonUser;
import icu.sehnen.common.result.CommonResult;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
 
/**
 * @Author : JCccc
 * @CreateTime : 2019/9/3
 * @Description :
 **/
@RestController
public class SendMessageController {
    @Autowired
    RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方法
    @RequestMapping("/sendRegisterDirectMessage")
    public void sendDirectMessage(@RequestBody  CommonUser commonUser) {
        //将消息携带绑定键值：TestDirectRouting 发送到交换机TestDirectExchange
        rabbitTemplate.convertAndSend("RegisterMsgDirectExchange", "RegisterMsgDirectRouting", commonUser);
    }

}
